package com.wn.inventory.web;

import com.wn.common.PageBean;
import com.wn.common.ResponseEntity;
import com.wn.entity.ReturnInWarehouseApplication;
import com.wn.inventory.service.ReturnInWarehouseApplicationService;
import com.wn.inventory.vo.ReturnInWarehouseApplicationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ author     ：NST
 * @ date       ：Created in 2022/10/21 15:31
 * @ description：
 * @ modified By：
 * @ version:
 */
@RestController
@RequestMapping("inventory/return")
public class ReturnInWarehouseApplicationController {
    @Autowired
    ReturnInWarehouseApplicationService returnInWarehouseApplicationService;

    /**
     * @param returnInWarehouseApplication
     * @return com.wn.common.ResponseEntity
     * @ author nst
     * @ date 2022/10/21 15:32
     * @ Description 前台需要提供申请人id,库存台账id,数量，流程id(测试，后续由流程模块获取)
     */
    @RequestMapping("add")
    public ResponseEntity add(@RequestBody @Validated ReturnInWarehouseApplication returnInWarehouseApplication, HttpServletRequest request) {
        returnInWarehouseApplicationService.insert(returnInWarehouseApplication,request);
        return ResponseEntity.success;
    }

    @RequestMapping("addition")
    public ResponseEntity getByCondition(@RequestBody ReturnInWarehouseApplicationVo returnInWarehouseApplicationVo) {
        PageBean<ReturnInWarehouseApplication> pageBean = returnInWarehouseApplicationService.getByCondition(returnInWarehouseApplicationVo);
        return new ResponseEntity(pageBean);
    }


}
